<?php
/**
 * @version		$Id: dashboard.php 25 2010-09-08 15:16:11Z joomlaworks $
 * @package		K2mart
 * @author    JoomlaWorks http://www.joomlaworks.gr
 * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
 * @license		Commercial - This code cannot be redistributed without permission from Nuevvo Webware Ltd.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class K2martModelDashboard extends JModel {

	function countK2Items(){
		jimport('joomla.filesystem.file');
		if(!JFile::exists(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'k2.php'))
			return JText::_('K2 was not found on your system');
		$db = & JFactory::getDBO();
		$query = "SELECT COUNT(*) FROM #__k2_items";
		$db->setQuery($query);
		$result = $db->loadResult();
		return $result;
	}

	function countVmProducts(){
		jimport('joomla.filesystem.file');
		if(!JFile::exists(JPATH_SITE.DS.'components'.DS.'com_virtuemart'.DS.'virtuemart.php'))
			return JText::_('Virtuemart was not found on your system');
		require_once(JPATH_SITE.DS.'components'.DS.'com_virtuemart'.DS.'virtuemart_parser.php');
		$vmDB = new ps_DB;
		$query = "SELECT COUNT(*) FROM #__{vm}_product WHERE product_parent_id=0";
		$vmDB->setQuery($query);
		$result = $vmDB->loadResult();
		return $result;
	}
	
	function countK2martProducts(){
		$db = & JFactory::getDBO();
		$query = "SELECT COUNT(*) FROM #__k2mart";
		$db->setQuery($query);
		$result = $db->loadResult();
		return $result;
	}
}
